<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="./img/sd.png">
<title>街灯</title>
<style>
		body{
		height: 100%;
		width: 100%;
		padding: 0px 0px 0px 0px;
		margin: 0px 0px 0px 0px;
		background-size: cover;
		}
		#wenzi{
			color: #000000;
			font-size:20px;
			font-weight:bold;
			font-family: 微软雅黑;
		}
		#input1{
			outline: none;
		}
		#input1:focus{
			outline: none;
		}
		#input2{
			width: 25.5px;
			height: 25.5px;
			background-color:#fff;
			padding: 10px;
			margin: 12px 12px 0px 0px;
		}
		#input2:hover{
			background-color: #D3D3D3;
		}
</style>
</head>
<font face:微软雅黑>
<body>
	<center>
	<div style="width: 800px;height: 100%;">
		<!--第一部分-->
		<div style="width: 100%;height: 100%;text-align:left;padding: 0px;margin: 20px 0px 0px 0px;">
			<!--判断登录-->
			<?php
				error_reporting(0);
				$jduser = $_COOKIE["jduser"];//获取cookie用户名
				$jdQQ =$_COOKIE["jdQQ"];//获取cookie QQ号
				$ip = $_SERVER["REMOTE_ADDR"];//获取IP
				$s = $_GET['s'];//防止刷新
				$neirong = $_POST['neirong'];//接收输入内容
				$neirong=str_ireplace("<","&lt;",$neirong);//转义
				$neirong=str_ireplace(">","&gt;",$neirong);
				require_once('./config.php');
				$con=login();//链接数据库
				if ($jduser == NULL and $jdQQ == NULL)//判断用户名以及QQ号
				{
					echo 
					"<p style='color: #ffffff;padding: 10px 0px 10px 0px;margin:0px;font-weight:bold;font-family: 微软雅黑;background-color: #800000;width: 100%;text-align:center;border-radius:10px;width: 100%;'>暂未登录，仅支持预览，登录后可进行操作</p>";
				}
				else
				{
					echo
					"<div style='width: 100%;padding: 10px;margin:0px 0px 15px 0px;box-shadow: 0px 0px 3px #888888;border-radius: 10px;background-color:#fff;'>".
						
						"<form action='liuyanweidengl.php?s=1' method='post' style='width: 100%;display: flex;'>".
							"<textarea id='input1' placeholder='请输入内容！仅限255个字符' name='neirong' style='font-size:10px;height: 60px; width: 100%;border: 0px;font-family:微软雅黑;color:#000000;resize: none;padding: 5px;margin:0px;' onKeyUp='if(this.value.length > 500) this.value=this.value.substr(0,73)'></textarea>".
							"<input id='input2' type='image'  src='./img/pencil-plus-outline-custom.png' >".
						"</form>".
					"</div>";
					if (!$con)
					{
						die('MYSQL链接失败: ' . mysqli_error());
					}
					if ($neirong!=NULL)
					{
						$sql="INSERT INTO chat(yonghuming,neirong,ip,QQ,transit) VALUES('$jduser','$neirong','$ip','$jdQQ','false')";
						mysqli_query($con,$sql);
						echo '<script> alert("已发送，核审中....."); </script>';
					}
					elseif($s!=NULL and $neirong==NULL)
					{
						echo '<script> alert("请输入内容。"); </script>';
					}
				}
			    ?>
		</div>
		<!--第二部分-->
		<div style="width: 100%;padding:0px;margin: 15px 0px 0px 0px;">
			<?php
				error_reporting(0);
				$search = $_GET['search'];//防止刷新
				$search=str_ireplace("<","&lt;",$search);//转义
				$search=str_ireplace(">","&gt;",$search);
				require_once('./config.php');
				$con=login();//链接数据库
			   // $con = mysqli_connect("192.168.77.43:3306","jiedeng","11111111");
			   
			   if (!$con)
				{
					die('MYSQL链接失败: ' . mysqli_error());
				}
				else
				{
					//输出所有结果
					$sql = "SELECT * FROM chat where transit = 'true' order by id desc ";
					$result = mysqli_query($con,$sql);
					while($row = mysqli_fetch_array($result))
					  {
						  echo
						  "<div style='height: auto;width: 820px;margin:0px 0px 15px 0px;background-color: #ffffff;padding: 5px 0px 15px 0px;text-align: left;box-shadow: 0px 0px 3px #888888;border-radius: 10px;'>".
							"<div style='text-align: left;display: flex;padding: 0px 15px 0px 15px;margin:15px 0px 0px 0px;height: 60px;'>".
								"<div style='margin: 0px 0px 0px 10px;'>".
									"<p style='height: 20px;margin: 0px;padding: 0px;color: #000000;font-size:17px;font-weight:bold;font-family: 微软雅黑;'>".$row['yonghuming']."</p>".	
									"<p style='text-align: center;margin:5px 0px 0px 0px;padding: 1px 3px 1px 3px;color: #ffffff;font-size:10px;font-weight:bold;font-family: 微软雅黑;background-color: #00214f;'>"."IP:".$row['ip']."</p>".
								"</div>".
							"</div>".
							"<hr style='border: 1px solid #A9A9A9;padding: 0px;margin: 0px 15px 5px 15px;'>".
							"<div style='text-align: left;padding:0px 15px 0px 15px;margin:0px;'>".
								"<p style='margin: 15px 0px 0px 0px;padding: 0px;text-align: left;color: #000000;font-size:17px;font-family: 微软雅黑;font-weight:bold;'>".$row['neirong']."</p>".
							"</div>".
						  "</div>";
					  }
				}
			?>
		</div>
	</div>
	</center>
</body>
</font>
</html>
